<template>


  <el-menu :default-openeds="opens" style="min-height: 100% ;overflow: hidden;padding: 0;margin: 0;border: none"
           background-color="#7DB6BF" text-color="#fff"
           default-active="/home"
           :collapse-transition="false" :collapse="isCollapse" router
           active-text-color="#ffd04b"
          >
    <div style="height: 60px;line-height: 60px;text-align: center">
      <img src="../assets/mylogo.png" alt="" style="width: 24px;  position: relative;top: 5px;margin-left: 3px">
      <b style="color: white;margin-left: 5px;font-size: 18px" v-show="logoTextShow">证书管理系统</b>
    </div>
    <div v-for="item in menus" :key="item.id">
<!--      有path 一级菜单-->
      <div v-if="item.path">
        <el-menu-item :index="item.path">
            <i :class="item.icon"></i>
            <span slot="title" >{{item.name}}</span>
        </el-menu-item>
      </div>
<!--      无path 二级菜单-->
      <div v-else>
        <el-submenu :index="item.id+''" v-if="item.children.length">
          <template slot="title">
            <i :class="item.icon"></i>
            <span slot="title" v-show="logoTextShow">{{item.name}}</span>
          </template>
          <div v-for="subItem in item.children" :key="subItem.id">
            <el-menu-item :index="subItem.path">
              <i :class="subItem.icon"></i>
              <span slot="title">{{subItem.name}}</span>
            </el-menu-item>
          </div>
        </el-submenu>
      </div>
    </div>

  </el-menu>
</template>

<script>
export default {
  name: "Aside",
  props:{
    isCollapse: Boolean,
    logoTextShow: Boolean
  },
  data(){
    return {
      menus: localStorage.getItem("menus")?JSON.parse(localStorage.getItem("menus")):[],
      opens: localStorage.getItem("menus")?JSON.parse(localStorage.getItem("menus")).map(v=>v.id+''):[]
    }
  },
  methods:{
    // handleSelect(index){
    //   console.log(index)
    //   console.log(this.$router.options.routes)
    // }
  }
}
</script>

<style>
.el-submenu__title i {
  color: #ffff;
}
.el-menu-item i {
  color: #ffff;
}
</style>